package com.rong.structural.bridgeModel;

public class BridgeTest {
    public static void main(String[] args) {
        Product a = new ProductA();
        a.setName("产品A");
        Color red = new Red();
        a.setColor(red);
        a.Operation();

    }
}

// 抽象产品
abstract class Product{
    private String name;

    protected  Color color;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public abstract void Operation();
}

class ProductA extends Product{

    @Override
    public void Operation() {
        color.operation(this.getName());
    }
}

interface Color{

    void operation(String name);

}

class Red implements Color{
    @Override
    public void operation(String name) {
        System.out.println("红色"+name);
    }
}

class Green implements Color{
    @Override
    public void operation(String name) {
        System.out.println("绿色"+name);
    }
}
